package com.wteam.untils;

import com.wteam.config.JWT.jwt;
import com.wteam.exception.JwtException;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MemberIdAndName {


    public String username ( String token){
//        String Membername = null;
        try {
            Map<String, Object> claims = jwt.parseJWT(token);
          String  Membername = (String) claims.get("username");
            return Membername;
        } catch (Exception e) {
            e.printStackTrace();
            throw  new JwtException("token_is_flase");

        }


    }

    public Integer Memberid (String token){
        try {
        Map<String, Object> claims = jwt.parseJWT(token);
        Integer memberId = (Integer) claims.get("id");
            return memberId;
    } catch (Exception e) {
        e.printStackTrace();
        throw  new JwtException("token_is_flase");

    }

    }

}
